package com.rjwh.dingdong.client.mvp.model.impl;

import com.aishua.lib.task.AsResult;
import com.rjwh.dingdong.client.application.MyApplication;
import com.rjwh.dingdong.client.constant.LocalConstant;
import com.rjwh.dingdong.client.constant.NetConstant;
import com.rjwh.dingdong.client.mvp.BaseModel;
import com.rjwh.dingdong.client.mvp.BasePresenter;
import com.rjwh.dingdong.client.mvp.model.ICommunityPostPublishModel;
import com.rjwh.dingdong.client.network.HttpWebService;
import com.rjwh.dingdong.client.network.HttpWebServiceCallBack;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Kay
 * @ClassName CommunityPostPublishModel
 * @Description
 * @date 2016-7-18
 * @history 2016-7-18 author: description:
 */
public class CommunityPostPublishModel extends BaseModel implements ICommunityPostPublishModel, HttpWebServiceCallBack {


    public CommunityPostPublishModel(BasePresenter basePresenter) {
        super(basePresenter);
    }

    @Override
    public void doPublishTopic(String modularid, String title, String content, String attachids, String tagids, String address) {
        Map<String, String> publishTopicParams = new HashMap<String, String>();
        publishTopicParams.put("userid", MyApplication.spUtil.getStrPreferenceByParamName(MyApplication.app, LocalConstant.SP_USERID));
        publishTopicParams.put("username", MyApplication.spUtil.getStrPreferenceByParamName(MyApplication.app, LocalConstant.SP_USERNAME));
        publishTopicParams.put("modularid", modularid);
        publishTopicParams.put("title", title);
        publishTopicParams.put("content", content);
        publishTopicParams.put("attachids", attachids);
        publishTopicParams.put("tagids", tagids);
        publishTopicParams.put("address", address);
        HttpWebService.getDataFromServer(NetConstant.COMMUNITY_PUBLISHTOPIC, publishTopicParams, true, this);
    }

    @Override
    public void doPublishReply(String modularid, String topicid, String parentid, String replyid, String title, String content, String attachids, String address) {
        Map<String, String> publishReplyParams = new HashMap<String, String>();
        publishReplyParams.put("userid", MyApplication.spUtil.getStrPreferenceByParamName(MyApplication.app, LocalConstant.SP_USERID));
        publishReplyParams.put("username", MyApplication.spUtil.getStrPreferenceByParamName(MyApplication.app, LocalConstant.SP_USERNAME));
        publishReplyParams.put("modularid", modularid);
        publishReplyParams.put("topicid", topicid);
        publishReplyParams.put("parentid", parentid);
        publishReplyParams.put("replyid", replyid);
        publishReplyParams.put("title", title);
        publishReplyParams.put("content", content);
        publishReplyParams.put("attachids", attachids);
        publishReplyParams.put("address", address);
        HttpWebService.getDataFromServer(NetConstant.COMMUNITY_PUBLISHREPLY, publishReplyParams, true, this);
    }

    @Override
    public void onServerDataAcquired(int businessType, AsResult mAsResult, boolean isRefresh) {
        if (getBasePresenter() != null)
            getBasePresenter().onServerDataAcquired(businessType, mAsResult, isRefresh);
    }
}
